<?php
/**
 * format date helper
 *
 * @author kim
 */
class App_View_Helper_Fdate extends Zend_View_Helper_Abstract
{
    /**
     * Generate the formatted date by default/given format
     *
     * @access public
     *
     * @param  string $datetime - for example : 2011-04-20 08:21:11
     * @param  string $format - the date format type, by default '1' : "April 21, 2011 - 12:35pm"
     * @return string - default formatted date
     */
    public function Fdate($datetime, $format = '1')
    {
        $date = '';
        if (is_string($datetime)) {
            if ($format == '1') {
                $f = 'F j, Y - g:i';
                $ampm = date('G', strtotime($datetime)) > 11 ? ' pm' : ' am';
            } else if ($format == '2') {
                $f = 'F j, Y';
                $ampm = '';
            } else {
                $f = 'F j';
                $ampm = '';
            }

            $date = date($f, strtotime($datetime)) . $ampm;
        }
        return $date;
    }
}